package com.bysj.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.bysj.system.domain.Citys;
import com.bysj.system.service.ICitysService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政区域地州市信息Controller
 *
 * @author bysj
 * @date 2024-02-03
 */
@RestController
@RequestMapping("/system/citys")
public class CitysController extends BaseController
{
    @Autowired
    private ICitysService citysService;

    /**
     * 查询行政区域地州市信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:citys:list')")
    @GetMapping("/list")
    public TableDataInfo list(Citys citys)
    {
        startPage();
        List<Citys> list = citysService.selectCitysList(citys);
        return getDataTable(list);
    }

    /**
     * 导出行政区域地州市信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:citys:export')")
    @Log(title = "行政区域地州市信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Citys citys)
    {
        List<Citys> list = citysService.selectCitysList(citys);
        ExcelUtil<Citys> util = new ExcelUtil<Citys>(Citys.class);
        util.exportExcel(response, list, "行政区域地州市信息数据");
    }

    /**
     * 获取行政区域地州市信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:citys:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(citysService.selectCitysById(id));
    }

    /**
     * 新增行政区域地州市信息
     */
    @PreAuthorize("@ss.hasPermi('system:citys:add')")
    @Log(title = "行政区域地州市信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Citys citys)
    {
        return toAjax(citysService.insertCitys(citys));
    }

    /**
     * 修改行政区域地州市信息
     */
    @PreAuthorize("@ss.hasPermi('system:citys:edit')")
    @Log(title = "行政区域地州市信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Citys citys)
    {
        return toAjax(citysService.updateCitys(citys));
    }

    /**
     * 删除行政区域地州市信息
     */
    @PreAuthorize("@ss.hasPermi('system:citys:remove')")
    @Log(title = "行政区域地州市信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(citysService.deleteCitysByIds(ids));
    }
}
